const fs = require("fs");
const path = require("path");

/*fs.readFile('./src/a.json', (err, data) => {
	const result = JSON.parse(data)
	console.log(result)
	
	fs.readFile(result.next, (err, data) => {
		const result = JSON.parse(data)
		console.log(result)
		
		fs.readFile(result.next, (err, data) => {
			const result = JSON.parse(data)
			console.log(result)
			
			
		});
		
		console.log(`1123213`)
		
	});
	
});*/


const readFile = (path) => {
		return new Promise((resolve, reject) => {
			fs.readFile(path, (err, data) => {
				const result = JSON.parse(data)
				resolve(result)
			});
		})
	}
	
	/*readFile('./src/a.json')
		.then(res => {
			console.log(res)
			return readFile(res.next)
		})
		.then(res => {
			console.log(res)
			return readFile(res.next)
		})
		.then(res => {
			console.log(res)
		})*/

;(async function () {
	const res1 = await readFile('./src/a.json')
	console.log(res1)
	const res2 = await readFile(res1.next)
	console.log(res2)
	const res3 = await readFile(res2.next)
	console.log(res3)
})()

setTimeout(() => {
	console.log(2)
})

console.log(1)
